namespace Home.Domain.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class _527 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Success",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 60),
                        Body = c.String(),
                        Pic = c.String(maxLength: 200),
                        Sort = c.Int(nullable: false),
                        CreateDate = c.DateTime(nullable: false),
                        BrandId = c.Int(nullable: false),
                        LeiBieId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Brand", t => t.BrandId, cascadeDelete: true)
                .ForeignKey("dbo.LeiBie", t => t.LeiBieId, cascadeDelete: true)
                .Index(t => t.BrandId)
                .Index(t => t.LeiBieId);
            
            CreateTable(
                "dbo.Brand",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(maxLength: 30),
                        Sort = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.LeiBie",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Title = c.String(maxLength: 30),
                        Sort = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            AlterColumn("dbo.Classification", "Sort", c => c.Int(nullable: false));
        }
        
        public override void Down()
        {
            DropIndex("dbo.Success", new[] { "LeiBieId" });
            DropIndex("dbo.Success", new[] { "BrandId" });
            DropForeignKey("dbo.Success", "LeiBieId", "dbo.LeiBie");
            DropForeignKey("dbo.Success", "BrandId", "dbo.Brand");
            AlterColumn("dbo.Classification", "Sort", c => c.String());
            DropTable("dbo.LeiBie");
            DropTable("dbo.Brand");
            DropTable("dbo.Success");
        }
    }
}
